home *** CD-ROM | disk | FTP | other *** search
- SHORT SHOTS - Quick Programming tips for the intrepid Clipper user
- =========================================================================
- Number 1 Published June 16, 1986
- =========================================================================
-
- DILEMMA : You want to de-activate use of the <ALT>C key combination, but
- you still want your user's to be able to use the <ESC> key to
- exit reads and other routines. You can't use SET ESCAPE OFF
- because that will disable both <ALT>C and <ESC>. What to do,
- what to do???
-
- SOLUTION: Use a combination of the new Clipper commands, SET KEY and
- KEYBOARD. Here's the example:
-
- *************************************************************************
- *** Filename: SETESC.PRG
- *** Purpose : Demonstrates method of defeating <ALT>C while leaving
- *** the ESC key active.
- *************************************************************************
-
- CLEAR
- m_name = SPACE(20)
-
- SET KEY 302 TO NullKey && Sets <ALT>C to a null
-
- DO WHILE .T.
- @ 5,10 SAY "Your Name: " GET m_name
- READ
- IF TRIM(m_name) == ""
- WAIT "Press any key to Quit..."
- QUIT
- ENDIF
- ENDDO
-
- *** Procedure NullKey stuffs a null string into the keyboard buffer
-
- PROCEDURE NullKey
-
- *** supply some dummy parameters so Clipper stays happy
-
- PARAMETERS top,bottom,out
- KEYBOARD = ""
- RETURN
-
- *** EOF SETESC.PRG
-
- -More-
-
- >>> CLIPPER'S KEYBOARD vs DBASE'S SET TYPEAHEAD
- submitted by David Morgan Published June 24, 1986
- ==========================================================================
-
- Even though Clipper's KEYBOARD command and dBASE's SET TYPEAHEAD command
- can acheive some similar results, there are distinct differences in usage
- between the two.
-
- Both Clipper and dBASE use a keyboard buffer. This buffer is a holding
- area where characters, keyed while a program is running, are stored and not
- sent to the screen or otherwise processed by the program immediately. The
- buffer places the incoming characters in a queue, (which means that it
- "stands them in line" in the same order as they were keyed), from which
- characters are extracted by the program on a "first in first out" basis.
- Where there is no keyboard buffer in a program, keystrokes occuring while
- an application is busy (e.g., performing a lengthy print job) must be
- ignored. And the operator has to wait till the program is ready before
- keying. dBASE will create a keyboard buffer 20 characters in length and
- Clipper will create one of 16 characters, by default.
-
- In dBASE, SET TYPEAHEAD actually varies the buffer size. If you use SET
- TYPEAHEAD to reduce size of the buffer it will discard all the characters
- in the queue that exceed the new buffer size.
-
- While Clipper does not allow you to "size" the keyboard buffer, its
- KEYBOARD command does allow wholesale replacement of buffer contents. This
- really puts buffer contents under your control. For example:
-
- KEYBOARD "ABCD"
-
- loads the characters ABCD into the buffer. Whatever was in there before is
- overwritten and at the very next input point in your program (a READ,
- ACCEPT, INPUT, WAIT) "ABCD" is issued to the proper output device (screen,
- printer, etc.). After this, the keyboard buffer is empty.
-
- Both the KEYBOARD and SET TYPEAHEAD commands can be used to flush the
- keyboard buffer. In dBASE, 'SET TYPEAHEAD TO 0' will flush any characters
- in the buffer and re-set the buffer to a size of zero for the remainder of
- the program or until a new SET TYPEAHEAD command is issued. Using the
- command line
-
- KEYBOARD ""
-
- in Clipper, on the other hand, will clear the buffer only once and must be
- issued everytime that you want it flushed.